import { request } from '@/service/request';

/** 获取通话记录列表 */
export function fetchGetOutboundCallRecordList(params?: Api.Outbound.CallRecordSearchParams) {
  return request<Api.Outbound.CallRecordList>({
    url: '/outbound/record/list',
    method: 'get',
    params
  });
}

/** 获取通话记录详情 */
export function fetchGetOutboundCallRecord(callId: string) {
  return request<Api.Outbound.CallRecord>({
    url: `/outbound/record/${callId}`,
    method: 'get'
  });
}

/** 删除通话记录 */
export function fetchDeleteOutboundRecord(callIds: string[]) {
  return request<boolean>({
    url: '/outbound/record',
    method: 'delete',
    data: { callIds }
  });
}

/** 获取录音地址 */
export function fetchGetRecordUrl(callId: string) {
  return request<{ recordUrl: string }>({
    url: `/outbound/record/${callId}/record`,
    method: 'get'
  });
}

/** 根据号码查询通话记录 */
export function fetchGetCallsByPhone(phone: string) {
  return request<Api.Outbound.CallRecord[]>({
    url: `/outbound/record/by-phone/${phone}`,
    method: 'get'
  });
}

/** 导出通话记录 */
export function fetchExportOutboundCallRecord(params: any) {
  return request<any>({
    url: '/outbound/record/export',
    method: 'post',
    data: params,
    responseType: 'blob'
  });
}
